package nl.windgazer.arachne.components.yql;

import nl.windgazer.arachne.mixins.RenderInformalElement;

import org.apache.tapestry5.annotations.Mixin;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.json.JSONObject;

/**
 * This component attempts to display a flickr photo. It expects a JSONOBject adhering to the following structure:<br />
 * <pre>{
 *     "farm": "4",
 *     "height_m": "332",
 *     "height_s": "159",
 *     "height_sq": "75",
 *     "height_t": "66",
 *     "id": "2669726717",
 *     "isprimary": "0",
 *     "secret": "458ae70249",
 *     "server": "3228",
 *     "title": "One wonder why even warn about this in the outback?",
 *     "url_m": "http://farm4.static.flickr.com/3228/2669726717_458ae70249.jpg",
 *     "url_s": "http://farm4.static.flickr.com/3228/2669726717_458ae70249_m.jpg",
 *     "url_sq": "http://farm4.static.flickr.com/3228/2669726717_458ae70249_s.jpg",
 *     "url_t": "http://farm4.static.flickr.com/3228/2669726717_458ae70249_t.jpg",
 *     "width_m": "500",
 *     "width_s": "240",
 *     "width_sq": "75",
 *     "width_t": "100"
 *     "photopage": "http://www.flickr.com/photos/windgazer/2669726717/"
 *}</pre>
 * 
 * @author mreuring
 *
 */
public class YQLFlickrPhoto {

	//Injects and Persists

	//Properties and Parameters

	@Parameter(name="value",required=true)
	private JSONObject photo;

	//Components

	@SuppressWarnings("unused")
	@Mixin
	private RenderInformalElement _informal;

	//Events
	//Other (check for business-logic, it should not remain here)

	public String getJSON() {
		return photo.toString();
	}

	public String getTitle() {
		return photo.getString("title");
	}

	public String getSquare() {
		return photo.getString("url_sq");
	}

	public String getSmall() {
		return photo.getString("url_s");
	}

	public String getMedium() {
		return photo.getString("url_m");
	}

	public String getThumbnail() {
		return photo.getString("url_t");
	}

	public String getLarge() {
		return photo.getString("url_l");
	}

	public String getOriginal() {
		return photo.getString("url_o");
	}

	public String getPhotopage() {
		return photo.getString("photopage");
	}

}
